# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-pytest-isort
pkgver=3.1.0
pkgrel=2
pkgdesc='pytest plugin to perform isort checks (import ordering)'
arch=('any')
license=('BSD')
url='https://github.com/moccu/pytest-isort'
depends=('python-pytest' 'python-isort')
makedepends=('python-build' 'python-installer' 'python-poetry-core')
source=("https://github.com/moccu/pytest-isort/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('a01799b832783301818aba5d441cdb9167a367e2c434df9790e4b2d839a9cdab03683736f43339a07ef4444ca0bddfb1b6cd503db170b6544f8c14617e7398df')

build() {
  cd pytest-isort-$pkgver
  python -m build -nw
}

check() {
  # Hack entry points by installing it

  cd pytest-isort-$pkgver
  python -m installer --destdir="$PWD/tmp_install" dist/*.whl
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  PYTHONPATH="$PWD/tmp_install/$site_packages:$PYTHONPATH" pytest
}

package() {
  cd pytest-isort-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE.rst -t "$pkgdir"/usr/share/licenses/$pkgname/
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  rm "$pkgdir"/$site_packages/LICENSE.rst
}

# vim:set ts=2 sw=2 et:
